<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>纯净水世界管理后台</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href='/layui/css/layui.css'>
	<link rel="stylesheet" href='/stylesheets/management.css'>
	<style>
		table thead tr th:first-child {
			width: 10% !important;
		}

		table thead tr th:last-child {
			width: 25% !important;
		}
	</style>
</head>

<body>
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo layui-hide-xs layui-bg-black">纯净水世界</div>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item layui-hide layui-show-sm-inline-block">
					<a href="javascript:;">
						<img src="//unpkg.com/outeres@0.0.10/img/layui/icon-v2.png" class="layui-nav-img">
						<% if (_adminname=='-null' ){ %>
							登录
							<% }else{ %>
								<%=_adminname %>
									<% } %>
					</a>
					<dl class="layui-nav-child">
						<dd><a href="/management/myinfo">个人资料</a></dd>
						<dd><a href="/management/loginOut">退出登录</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
					<a href="javascript:;">
						<i class="layui-icon layui-icon-more-vertical"></i>
					</a>
				</li>
			</ul>
		</div>
		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" lay-filter="test">
					<li class="layui-nav-item layui-nav-itemed">
						<a class="" href="javascript:;">信息管理模块</a>
						<dl class="layui-nav-child">
							<dd><a href="/management/school">高校信息管理</a></dd>
							<dd><a href="/management/area">园区信息管理</a></dd>
							<dd><a href="/management/build">楼栋信息管理</a></dd>
							<dd><a href="/management/room">宿舍信息管理</a></dd>
							<dd><a href="/management/student">学生信息管理</a></dd>
							<dd><a href="/management/order"
									style="background-color: #16baaa; color: rgb(255, 255 ,255);">订单信息管理</a></dd>
							<dd><a href="/management/commodity">商品信息管理</a></dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">个人中心</a>
						<dl class="layui-nav-child">
							<dd><a href="/management/myinfo">个人信息</a></dd>
							<dd><a href="/management/changepwd">修改密码</a></dd>
						</dl>
					</li>
					<li class="layui-nav-item"><a href="/management/loginOut">退出登录</a></li>
				</ul>
			</div>
		</div>
		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">
				<div class="layui-elem-quote layui-text">
					<!-- 搜索、查询、添加 -->
					<form action="/management/order/main" method="get">
						<div
							style="display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: flex-start;align-items: center;">
							搜索：
							<input type="text" name="select" placeholder="订单信息搜索" class="layui-input"
								style="width: 20%;margin-right: 16px;" value="" />
							<input type="submit" class="layui-btn layui-btn-primary layui-btn-xs" value="查询" />
							<a href="/management/order/insert" class="layui-btn layui-btn-primary layui-btn-xs">添加</a>
						</div>
					</form>
				</div>
				<div class="layui-card layui-panel">
					<div class="layui-card-header">
					</div>
					<div class="layui-card-body">
						<table class="layui-table" lay-even>
							<colgroup>
								<col width="150">
								<col width="150">
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>订单ID</th>
									<th>商品ID</th>
									<th>数量</th>
									<th>总金额</th>
									<th>订单状态</th>
									<th>下单时间</th>
									<th>学生学号</th>
									<th>学校ID</th>
									<th>宿舍园区ID</th>
									<th>楼栋ID</th>
									<th>宿舍ID</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<% DB.forEach (function (item, iindex) { %>
									<tr>
										<td>
											<%= item.OrderID %>
										</td>
										<td>
											<%= item.CommodityID %>
										</td>
										<td>
											<%= item.Quantity %>
										</td>
										<td>
											<%= item.Total %>
										</td>
										<td>
											<%= item.State %>
										</td>
										<td>
											<%= item.Time.toLocaleString() %>
										</td>
										<!-- .toLocaleString()是将存储的时间转化成本地时间 如《Fri Dec 01 2023 00:02:21 GMT+0800 (中国标准时间)》转化成《2023/12/1 00:02:21》 -->
										<td>
											<%= item.StuNum %>
										</td>
										<td>
											<%= item.SchoolID %>
										</td>
										<td>
											<%= item.Dorm_AreaID %>
										</td>
										<td>
											<%= item.Dorm_BuildID %>
										</td>
										<td>
											<%= item.Dorm_RoomID %>
										</td>
										<td>
											<% for(var i=item.State+1;i<=4;i++) { %>
												<% if(i==0) { %>
													<a href="/management/order/state?type=delete&&value=<%= item.OrderID %>"
														class="caozuo"
														style="background-color: rgb(255, 0, 0);">已拒单，点击删除订单</a>
													<% break;} %>
														<% if(i==1) { %>
															<a href="/management/order/state?type=Rejection&&value=<%= item.OrderID %>"
																class="caozuo"
																style="background-color: rgba(238, 153, 153, 0.87);">拒单</a>
															<% } %>
																<% if(i==2) { %>
																	<a href="/management/order/state?type=take_orders&&value=<%= item.OrderID %>"
																		class="caozuo"
																		style="background-color: rgba(30, 153, 255, 0.5);">接单</a>
																	<% } %>
																		<% if(i==3) { %>
																			<a href="/management/order/state?type=distribution&&value=<%= item.OrderID %>"
																				class="caozuo"
																				style="background-color: rgba(255, 184, 0, 0.5);">配送</a>
																			<% } %>
																				<% if(i==4) { %>
																					<a href="/management/order/state?type=completed&&value=<%= item.OrderID %>"
																						class="caozuo"
																						style="background-color: rgba(22, 186, 170, 0.5);">完成</a>
																					<% } %>
																						<% } %>
																							<% if(item.State>=4) { %>
																								<a href="/management/order/state?type=delete&&value=<%= item.OrderID %>"
																									class="caozuo"
																									style="background-color: rgba(41, 44, 44, 0.8);">删除订单</a>
																								<% } %>
										</td>
									</tr>
									<% }); %>
							</tbody>
						</table>
					</div>
				</div>
				<br><br>
			</div>
		</div>
		<div class="layui-footer">
			<!-- 底部固定区域 -->
			底部固定区域
		</div>
	</div>

	<script src="/layui/layui.js"></script>
	<script>
		//JS 
		layui.use(['element', 'layer', 'util'], function () {
			var element = layui.element;
			var layer = layui.layer;
			var util = layui.util;
			var $ = layui.$;

			//头部事件
			util.event('lay-header-event', {
				menuLeft: function (othis) { // 左侧菜单事件
					layer.msg('展开左侧菜单的操作', {
						icon: 0
					});
				},
				menuRight: function () { // 右侧菜单事件
					layer.open({
						type: 1,
						title: '更多',
						content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
						area: ['260px', '100%'],
						offset: 'rt', // 右上角
						anim: 'slideLeft', // 从右侧抽屉滑出
						shadeClose: true,
						scrollbar: false
					});
				}
			});
		});
	</script>
</body>